package site;

import java.io.Serializable;
import java.util.Collection;
import java.util.Vector;
import javax.persistence.*;

@Entity
@NamedQueries({
	@NamedQuery(name="verif",query="select u.login from Utilisateur u"),
	@NamedQuery(name="Nom",query="select u.nom from Utilisateur u where u.login = :login "),
	@NamedQuery(name="Prenom",query="select u.prenom from Utilisateur u where u.login = :login "),
	@NamedQuery(name="idLogin",query="select u.id from Utilisateur u where u.login = :login "),
	@NamedQuery(name="idPW",query="select u.id from Utilisateur u where u.password = :password "),
})
@Inheritance(strategy=InheritanceType.JOINED)
public class Utilisateur implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id 
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="id")
	private int id = 0;
	
	@Column(name="nom")
	private String nom ;
	
	@Column(name="prenom")
	private String prenom ;
	
	@Column(name="password")
	private String password ;
	
	@Column(name="login")
	private String login ;
	
	@Column(name="email")
	private String email ;
	
	@ManyToMany(cascade = CascadeType.ALL)
	@JoinTable(name="PersonneActivite",
	joinColumns=
	@JoinColumn(name="idPersonne",
	referencedColumnName="id"),
	inverseJoinColumns=
	@JoinColumn(name="idActivite",
	referencedColumnName="identActivite"))
	private Collection<Activite> activites = new Vector<Activite>();
	
	@ManyToMany(cascade = CascadeType.ALL)
	@JoinTable(name="PersonneReunion",
	joinColumns=
	@JoinColumn(name="idPersonne",
	referencedColumnName="id"),
	inverseJoinColumns=
	@JoinColumn(name="idReunion",
	referencedColumnName="ident"))
	private Collection<Reunion> reunions = new Vector<Reunion>();
	
	public Utilisateur() {
		
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getNom() {
		return nom;
	}

	public void setNom(String nom) {
		this.nom = nom;
	}

	public String getPrenom() {
		return prenom;
	}

	public void setPrenom(String prenom) {
		this.prenom = prenom;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public Collection<Activite> getActivites() {
		return activites;
	}

	public void setActivites(Collection<Activite> activites) {
		this.activites = activites;
	}

	public Collection<Reunion> getReunions() {
		return reunions;
	}

	public void setReunions(Collection<Reunion> reunions) {
		this.reunions = reunions;
	}

}
